// let endpoint = "http://192.168.23.65:8082";

// 获取网络协议
// var protocol = window.location.protocol;
// // 获取主机名+端口号
// var domainPort = window.location.host;
// // 获取发布项目的名称
// // 获取路径
// // http://127.0.0.1/demo
// var endpoint = protocol + "//" + domainPort;
// let endpoint = "http://172.23.176.35:8082";
// let endpoint = "http://192.168.22.23:8082";
let timeout = 3000;
let AUTH_TOKEN = ""
/******************* axios 请求公共配置 start *********************/

// axios.defaults.baseURL = endpoint;
axios.defaults.timeout = timeout;
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
axios.defaults.headers.post['Content-Type'] = 'application/json';

/******************* axios 请求公共配置 end   *********************/

// 所有的请求资源
let request_uri = {

    method_point_list: {
        url: "/methodPointList", desc: "切入点列表", config: {}, request : invoke
    },
    method_rule_list: {
        url: "/methodRuleList", desc: "切入点规则列表", config: {}, request : invoke
    },
    load_agent: {
        url: "/remoteLoadAgent", desc: "远程加载agent", config: {}, request : invoke
    },

    add_server: {
        url: "/addMethodPoint", desc: "添加切入点", config: {}, request : invoke
    },
    add_method_rule: {
        url: "/addMethodRule", desc: "添加切入点规则", config: {}, request : invoke
    },
    sync_method_rule: {
        url: "/syncMethodRule", desc: "同步规则", config: {}, request : invoke
    },
    modify_method_rule: {
        url: "/modifyMethodRule", desc: "修改规则", config: {}, request : invoke
    },
    delete_method_rule: {
        url: "/deleteMethodRule", desc: "删除规则", config: {}, request : invoke
    },
}

// 资源调用 callback 结果响应回调
function invoke(data, callback) {
    axios.post(this.url, data, this.config).then(callback)
}
function base_callback(result){
    if (result.data.code === 200) {
        alert('operation success')
    } else {
        alert(result.data.msg)
    }
}

/*
function test_callback(result) {
    console.log(result.data)
}
request_uri.test.request({"name": "zhangsan"}, test_callback)
*/


